Part 6: Basic Panaromic Stitching

Implementation Details: In the case of implementing Panaromic Stitching sequentially by stitching the panaromic canvas with every new image, a significant reduction in size of stitched images is observed. In order to overcome this challenge, one image is chosen to be the reference image to which other images are stitched. In the implementation below, image 3 is chosen to be the reference and there the homography matrix between each of the other images and image 3 is computed in order to stitch the images. Thus the homography matrices obtained are H13,H23,H43 and H53 where Hij is the matrix used to stitch image i to image j. H13=H12 H23 H43=inverse(H34) H53=inverse(H34 H45)

H12,H23,H34,H45 are computed by stitching imaage 1 to image 2,image 2 to image 3,image 3 to image 4 and image 4 to image 5 respectively.

Stitching Image 1 to Image 2

In order to stitch image 1 to image 2, the sift keypoints and decriptors for each image is computed following which descriptors are used to compute all the matches between image 1 and image 2. The inliers are then extracted using RANSAC and are used to compute the homography matrix which is to be used to stitch image 1 to image 2. Here image 1 is interpolated to a scale of 18 while image 2 is interpolated to a scale of 4.

Reading image 1 and image 2 and computing SIFT keypoints and descriptors:

Obtaining matches for every descriptor:

Applying RANSAC to exract inliers from all matches:

Generating homography matrix using scaled inliers:

Transforming border position coordinates of image 1 to determine canvas size:

Placing interpolated image 2 on the canvas:

Transforming image 1 coordinates using homography matrix and placing on canvas:

Stitching Image 2 and Image 3

In order to stitch image 2 to image 3, the sift keypoints and decriptors for each image is computed following which descriptors are used to compute all the matches between image 2 and image 3. The inliers are then extracted using RANSAC and are used to compute the homography matrix which is to be used to stitch image 2 to image . Here image 2 is interpolated to a scale of 4 while scale of image 3 remains the same.

Reading image 2 and image 3 and computing their corresponding SIFT keypoints and descriptors:

Obtaining all matches for each descriptor of image 2 and 3.

Extracting inliers through RANSAC:

Interpolating image 2 and appending scaled inlier coordinates for computation of homography matrix: Here image 2 is scaled to a size of 4 while size of image 3 remains the same.

Computing Homography Matrix:

Displaying the stitched images:

Stitching Image 3 and Image 4

In order to stitch image 3 to image 4, the sift keypoints and decriptors for each image is computed following which descriptors are used to compute all the matches between image 2 and image 3. The inliers are then extracted using RANSAC and are used to compute the homography matrix which is to be used to stitch image 2 to image . Here image 4 is interpolated to a scale of 2 while scale of image 3 remains the same.

Reading images 3 and 4 and computing their corresponding SIFT Keypoints and Descriptors respectively:

Obtaining match for each descriptor in image 3 and 4:

Applying RANSAC to obtain the inliers:

Interpolating image 4 by scale 2 and appending the corresponding scaled inlier coordinates:

Computing homography matrix using original inliers obtained for image 2 and scaled inlier coordinates obtained for image 4:

Defining canvas to stitch images 3 and 4:

Placing image 4 onto the canvas:

Transforming image 3 coordinates using homography matrix and placing onto canvas:

Stitching Image 4 and Image 5:

In order to stitch image 3 to image 4, the sift keypoints and decriptors for each image is computed following which descriptors are used to compute all the matches between image 2 and image 3. The inliers are then extracted using RANSAC and are used to compute the homography matrix which is to be used to stitch image 2 to image . Here image 4 is interpolated to a scale of 2 while scale of image 3 remains the same.

Reading image 4 and 5 and computing their corresponding SIFT keypoints and descriptors respectively:

Obtaining matching descriptor for every descriptor in image 4 and image 5:

Obtaining inliers using RANSAC:

Interpolating and scaling image 4 by factor of 2 and image 5 by factor of 5 and appending their scaled inlier coordinates accordingly:

Computing the homography matrix:

Defining the canvas size through transformation of border coordinates of image 4:

Placing image 5 onto the canvas:

Stitching all images together

The necessary homography matrices required are computed using those obtained from above. These matrices are then used to stich each image to image 3 i)Image 1 has been interpolated and scaled by a factor of 18 ii)Image 2 has been interpolated and scaled by a factor of 4 iii)Image 3 remains in the same size iv)Image 4 has been interpolated and scaled by a factor of 2 v) Image 5 has been interpolated and scaled by a factor of 4

Obtaining the canvas size:

In order to determine the canvas size, the transformation coordinates are computed for each image usig their correponding homography matrix. The canvas size is then fixed depending upon the maximum and minimum values of the transformed coordinates for every image.

Defining the canvas

Placing image 3 onto the canvas:

Stitching every image to canvas: i) Stitching image 1 to canvas using H13:

Stitching image 2 to 3 using H23

Stitching image 4 to canvas using H43:

Stitching image 5 to canvas using H53 homography matrix:

Plotting Canvas containing all images stitched together: